package com.tanhua.server.service.impl;

import com.tanhua.dubbo.api.UserLocationApi;
import com.tanhua.model.vo.ErrorResult;
import com.tanhua.server.exception.BusinessException;
import com.tanhua.server.intercepter.UserThreadLocal;
import com.tanhua.server.service.BaiduService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class BaiduServiceImpl implements BaiduService {

    @DubboReference
    private UserLocationApi userLocationApi;

    //更新地理位置
    @Override
    public void updateLocation(Double longitude, Double latitude, String address) {

        //获取当前用户id
        Long userId = UserThreadLocal.getUserId();
        Boolean aBoolean =
                userLocationApi.updateLocation(userId, longitude, latitude, address);
        if (!aBoolean) {
            throw new BusinessException(ErrorResult.error());
        }

    }
}
